package com.kgc.ssm.mapper;

import com.kgc.ssm.entity.Orders;
import com.kgc.ssm.entity.Stock;
import com.kgc.ssm.entity.StockExample;
import java.util.List;
import java.util.Map;

import com.kgc.ssm.entity.dto.Result;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;

public interface StockMapper {
    long countByExample(StockExample example);

    int deleteByExample(StockExample example);

    int deleteByPrimaryKey(Long id);

    int insert(Stock row);

    int insertSelective(Stock row);

    List<Stock> selectByExampleWithRowbounds(StockExample example, RowBounds rowBounds);

    List<Stock> selectByExample(StockExample example);

    Stock selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("row") Stock row, @Param("example") StockExample example);

    int updateByExample(@Param("row") Stock row, @Param("example") StockExample example);

    int updateByPrimaryKeySelective(Stock row);

    int updateByPrimaryKey(Stock row);

    //这个查询是多表查询 为了物资名称这一个参数
    @Select("SELECT * " +
            "FROM STOCK s " +
            "JOIN ENQUIRE e ON s.ID = e.STOCK_ID " +
            "JOIN ENQUIRE_DETAIL ed ON e.ID = ed.ENQUIRE_ID;")
    List<Stock> findAll2();

    //根据id查询对应的数据 多表查询
    @Select("SELECT * " +
            "FROM STOCK s " +
            "JOIN ENQUIRE e ON s.ID = e.STOCK_ID " +
            "JOIN ENQUIRE_DETAIL ed ON e.ID = ed.ENQUIRE_ID " +
            "WHERE s.ID = #{id};")
    Map<String,Object> findById1(@Param("id") Integer id);;

    @Select("SELECT * " +
            "FROM STOCK s " +
            "JOIN ENQUIRE e ON s.ID = e.STOCK_ID " +
            "JOIN ENQUIRE_DETAIL ed ON e.ID = ed.ENQUIRE_ID " +
            "WHERE s.ID = #{id};")
    List<Map<String,Object>> findById(@Param("id") Integer id);;


    int updateAll(@Param("param") Map<String,Object> param);

    List<Orders> findUnStockOrdersByConditions(String materialCode,
                                               String materialName,
                                               String status,
                                               RowBounds rowBounds,
                                               String sortBy);

}